<!-- node 页面内容 -->
<section class="node" ng-controller="nodeCtrl">
    <!-- 面包屑导航 start -->
    <div class="row margin-reset breadcrumb-row">
        <ol class="breadcrumb padding-reset">
            <li ng-click="goBack();"><a>更多功能</a></li>
            <li class="li-1"><a>设置审核节点</a></li>
            <li class="li-2"><a ng-click="goBack();">返回上页</a></li>
        </ol>
    </div>
    <!-- 面包屑导航 end -->

    <!-- 标题内容 start -->
    <div class="row margin-reset head-row">
        <div class="panel yf-shadow">
            <div class="panel-heading">
                <div class="row margin-reset">
                    <div class="pull-right">
                        <a class="btn btn-mt-ok" data-toggle="modal" data-target="#newNodeModal" ng-click="cleanSelectedUsers();">添加节点</a>
                    </div>
                    <h4>设置审核节点</h4>
                </div>
            </div>
        </div>
    </div>
    <!-- 标题内容 end -->

    <!-- 列表项 start -->
    <div class="row margin-reset item-row" ng-repeat="node in nodes | orderBy: 'level' track by $index">
        <div class="panel yf-shadow">
            <div class="panel-body">
                <div class="row margin-reset">
                    <div class="pull-right">
                        <a class="btn btn-mt-ok btn-edit" ng-click="editNode($index);">修改</a>
                        <a class="btn btn-delete" ng-click="deleteNode(node.id);">
                            <i class="icon-delete"></i>
                        </a>
                    </div>
                    <div class="col-sm-6 col-xs-6">
                        <div class="row item-info-row">
                            节点{{$index + 1}} ：{{node.department.name}} / {{node.role.name}}
                        </div>
                        <div class="row item-info-row">
                            审核人：
                            <span ng-repeat="user in node.users track by $index">
                              {{user.real_name}}
                              <span ng-if="node.users.length > 1 && $index + 1 != node.users.length">、</span>
                            </span>
                            <!-- <a class="a-link" href="">添加审核人</a> -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 列表项 end -->

    <!-- 新增项 start -->
    <div class="modal fade common-modal new_node_modal" id='newNodeModal' tabindex="-1" role="dialog" aria-labelledby="common-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content yf-shadow">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h3 class="modal-title" id="common-modal">
                        新建节点
                    </h3>
                </div>
                <div class="modal-body">
                    <div class="row margin-reset">
                        <div class="col-xs-12">
                            <form action="" id="newForm">
                                <div class="form-group">
                                    <label for="">部门</label>
                                    <select id="department_id" ng-model="node.department_id" ng-options="department.id as department.name for department in departments" ng-change="changeDepartment();" class="form-control mt_input" required>
                                        <option value="" selected="true" disabled="true">请选择部门</option>
                                    </select>
                                </div>

                                <div class="form-group">
                                    <label for="">角色</label>
                                    <select id="department_role_id" disabled ng-model="node.department_role_id" ng-options="department_role.id as department_role.name for department_role in department_roles" ng-change="changeRole();" class="form-control mt_input" required>
                                        <option value="" selected="true" disabled="true">请选择角色</option>
                                    </select>
                                </div>

                                <div class="form-group">
                                    <label for="">审核人</label>
                                    <select id="user_ids" disabled ng-model="node.user" ng-options="user as user.real_name for user in users" ng-change="selectUser();" class="form-control mt_input" required>
                                        <option value="" selected="true" disabled="true">请选择审核人</option>
                                    </select>
                                    <div class="row margin-reset" id="user-ids-div">
                                        <div class="col-xs-4 user-ids-item" ng-repeat="selected_user in selected_users track by $index">
                                            {{selected_user.real_name}}
                                            <label for="" ng-click="deleteSelectedUsers('new', $index);">&times;</label>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <div class="row margin-reset">
                        <div class="col-xs-12">
                            <button type="submit" class="btn btn-mt-ok btn-block" ng-click="newNode();">
                              新建
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 新增项 end -->

    <!-- 修改项 start -->
    <div class="modal fade common-modal edit_node_modal" id='editNodeModal' tabindex="-1" role="dialog" aria-labelledby="common-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content yf-shadow">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h3 class="modal-title" id="common-modal">
                        修改节点
                    </h3>
                </div>
                <div class="modal-body">
                    <div class="row margin-reset">
                        <div class="col-xs-12">
                            <form action="" id="newForm">
                                <!--
                                    <div class="form-group">
                                        <label for="">部门</label>
                                        <select id="edit_department_id" ng-model="edit_node.department_id" ng-options="department.id as department.name for department in departments" ng-change="changeDepartment('edit');" class="form-control mt_input" required>
                                          <option value="" selected="true" disabled="true">请选择部门</option>
                                      </select>
                                    </div>

                                    <div class="form-group">
                                        <label for="">角色</label>
                                        <select id="edit_department_role_id"  ng-model="edit_node.depart_role_id" ng-options="department_role.id as department_role.name for department_role in department_roles" ng-change="changeRole('edit');" class="form-control mt_input" required>
                                          <option value="" selected="true" disabled="true">请选择角色</option>
                                      </select>
                                    </div>
                                -->

                                <div class="form-group">
                                    <label for="">审核人</label>
                                    <select id="edit_user_id"  ng-model="edit_node.user" ng-options="user as user.real_name for user in users" ng-change="selectUser('edit');" class="form-control mt_input" required>
                                      <option value="" selected="true" disabled="true">请选择审核人</option>
                                  </select>
                                    <div class="row margin-reset" id="user-ids-div">
                                        <div class="col-xs-4 user-ids-item" ng-repeat="selected_user in selected_users track by $index">
                                            {{selected_user.real_name}}
                                            <label for="" ng-click="deleteSelectedUsers('edit', $index);">&times;</label>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <div class="row margin-reset">
                        <div class="col-xs-12">
                            <button type="submit" class="btn btn-mt-ok btn-block" ng-click="editedNode();">
                              修改
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 修改项 end -->

</section>
